# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=reg
pkgver=0.16.1
pkgrel=20
pkgdesc="Docker registry v2 command line client and repo listing generator with security checks"
url="https://github.com/genuinetools/reg"
license="MIT"
arch="all !riscv64"
makedepends="go"
source="https://github.com/genuinetools/reg/archive/v$pkgver/reg-$pkgver.tar.gz"
options="chmod-clean"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-trimpath \
		-ldflags "
			-X github.com/genuinetools/reg/version.GITCOMMIT=v$pkgver
			-X github.com/genuinetools/reg/version.VERSION=$pkgver-r$pkgrel
			" \
		-o reg .
}

check() {
	## "make test" - modified (exclude broken tests)
	## https://github.com/genuinetools/reg/issues/187
	go test -v -tags "cgo" \
		$(go list ./... | grep -v vendor | grep -v 'github.com/genuinetools/reg$')
}

package() {
	install -Dm755 reg "$pkgdir"/usr/bin/reg
}

sha512sums="2be68b405bb384d8eb3ae17a9b1c802a7f3212865ce61cf72f01794b9456787b1ef0eb62a538735d119153b0f472e741a8bbe99f1ce70d3b16ce1b8ba90eb4b8  reg-0.16.1.tar.gz"
